/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-11-27
 * Time: 15:23
 */
//https://leetcode.cn/problems/remove-element/description/
class Solution1 {
    public int removeElement(int[] nums, int val) {
        //快慢指针
        int slow = 0;
        for (int fast = 0; fast < nums.length; fast++){
            //没遇到val之前，都是原地复制，当遇到val时，slow停下，fast继续直到遇到不是val的数
            if (nums[fast] != val){
                int temp = nums[slow];
                nums[slow] = nums[fast];
                slow++;
            }
        }
        return slow;
    }
}
